//Handler after imajnet was activated ImajnetPlugin.onImajnetActivated = function() { //Set coordinates var lon = 19.044818370966784; var lat = 47.50627357484566; //Get closest image to this coordinates ImajnetPlugin.getClosestImage(2.267, 48.895); } //Function that will get the closest image ImajnetPlugin.getClosestImage = function(lon, lat) { //Set imajnet mode to closest image; Imajnet.activateImajnetControl(null, 'closestImage'); //Pass the coordinates to the imajnet library ImajnetMap.mapClickHandler({ lon: lon, lat: lat }); } //Register events on the map to get oriented images on click ImajnetPlugin.registerMapEvents = function() { map.on('click', onMapClick); } function onMapClick(event) { var coordinate = ol.proj.transform(event.coordinate, webMercator, wgs84); ImajnetPlugin.getClosestImage(coordinate[0], coordinate[1]); }